package com.wanxi.myfor;

import java.util.Random;
import java.util.Scanner;

public class GuessNum {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Random random = new Random();
        int aa = random.nextInt(100);
        System.out.println("要猜的数为" + aa);
//
        while (true) {
            System.out.println("请输入一个数字");
            int num = scanner.nextInt();
            if (num > aa) {
                System.out.println("你猜大了");
            }
            if (num < aa) {
                System.out.println("你猜小了");
            }
            if (num == aa) {
                System.out.println("你猜对了");
                break;
            }
        }
    }
}
